def replace_and_update(file1_path, file2_path):
    try:
        # 读取文档 1 中的名字
        with open(file1_path, 'r', encoding='utf-8') as file1:
            names = file1.read().splitlines()

        # 生成替换后的命令列表
        commands = []
        for name in names:
            command = f"make simv tb_name={name}"
            commands.append(command)

        # 将替换后的命令写入文件 2
        with open(file2_path, 'w', encoding='utf-8') as file2:
            for command in commands:
                file2.write(command + '\n')

        print(f"文件 {file2_path} 的内容已被替换后的命令更新。")
    except FileNotFoundError:
        print("错误：指定的文件未找到。")
    except Exception as e:
        print(f"发生未知错误：{e}")


if __name__ == "__main__":
    # 请将下面的路径替换为实际路径
    file1 = 'test.txt'
    file2 = 'test_1.txt'
    replace_and_update(file1, file2)
    